﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows.Controls;

namespace CorporateGymManagementSystem
{
    public class IsEnabledConv : IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            bool isEnabled = true;

            foreach(object val in values)
            {
                if (val is TextBox)
                {
                    if(string.IsNullOrWhiteSpace((val as TextBox).Text))
                    {
                        isEnabled = false;
                    }
                }
            }

            return isEnabled;


            int iIndex1 = (int)(values[0]);

            bool bEnabled = false;

            if (values.Length == 1)
            {
                if (iIndex1 != -1)
                    bEnabled = true;
                else
                    bEnabled = false;
            }
            else
            {
                int iIndex2 = (int)(values[1]);
                if (iIndex1 != -1 && iIndex2 != -1)
                    bEnabled = true;
                else
                    bEnabled = false;
            }

            return bEnabled;
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotSupportedException("ConvertBack should never be called");
        }
    }
}
